package com.migo.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.migo.entity.ShOrderStatusLineEntity;
import com.migo.service.ShOrderStatusLineService;
import com.migo.utils.PageUtils;
import com.migo.utils.Query;
import com.migo.utils.R;


/**
 * 
 * 
 * @author powervision
 * @email wes.wang@powervision.me
 * @date 2018-12-06 10:51:54
 */
@RestController
@RequestMapping("shorderstatusline")
public class ShOrderStatusLineController {
	@Autowired
	private ShOrderStatusLineService shOrderStatusLineService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("shorderstatusline:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<ShOrderStatusLineEntity> shOrderStatusLineList = shOrderStatusLineService.queryList(query);
		int total = shOrderStatusLineService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(shOrderStatusLineList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("shorderstatusline:info")
	public R info(@PathVariable("id") Integer id){
		ShOrderStatusLineEntity shOrderStatusLine = shOrderStatusLineService.queryObject(id);
		
		return R.ok().put("shOrderStatusLine", shOrderStatusLine);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("shorderstatusline:save")
	public R save(@RequestBody ShOrderStatusLineEntity shOrderStatusLine){
		shOrderStatusLineService.save(shOrderStatusLine);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("shorderstatusline:update")
	public R update(@RequestBody ShOrderStatusLineEntity shOrderStatusLine){
		shOrderStatusLineService.update(shOrderStatusLine);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("shorderstatusline:delete")
	public R delete(@RequestBody Integer[] ids){
		shOrderStatusLineService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
